import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

public class shili7 {
    public static void main(String[] args) {
        try{
            Class clz = Class.forName("entity.Person");
            Constructor cl = clz.getDeclaredConstructor();
            Object obj = cl.newInstance();
            System.out.println(obj);


            Constructor c2 = clz.getDeclaredConstructor(String.class);
            c2.setAccessible(true);
            obj = c2.newInstance("New Person");
            System.out.println(obj);



            Constructor c3 = clz.getDeclaredConstructor(String.class,String.class,String.class);
            c3.setAccessible(true);
            obj = c3.newInstance("new Person", "beijing", "Hello");
            System.out.println(obj);



        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
    }
}
